<template>
  <div>
    <el-tree
      ref="tree"
      node-key="organizationId"
      :check-strictly="true"
      style="width: 300px; height: 400px; overflow: auto"
      default-expand-all
      :data="dataTree"
      :props="propsTree"
      show-checkbox
      @check-change="handleCheckChange"
    />
  </div>
</template>

<script setup name="intelligence">
import {
  // 组织结构数据
  selectOrganizationTreeapi,
} from "@/api/main/api.js";
import { toRefs, ref, reactive } from "vue";
const props = defineProps({
  organizationId: {
    type: String,
    default: [],
  },
});
const isShowWorkArea = ref(false);
const tree = ref(null);
const emit = defineEmits(["handleCheckTree"]);
const data = reactive({
  intelligenceList: [],
  propsTree: {
    label: "organizationFullName",
    children: "children",
  },
  dataTree: [],
});
const { dataTree, propsTree } = toRefs(data);
//智能推荐池 桥隧涵保养修, 线路保养修, 信号保养修
function getList() {
  selectOrganizationTreeapi({ organizationId: props.organizationId, organizationStatev: 0 }).then((res) => {
    if (res.code == 200) {
      dataTree.value = res.data;
    }
  });
}
getList();

//树结构的选择单选
function handleCheckChange(data, checked, indeterminate) {
  if (checked) {
    nextTick(() => {
      tree.value.setCheckedNodes([data]);
      emit("handleCheckTree", data);
    });
  }
}
</script>
<style scoped lang="scss"></style>
